// ProfilerCallbackServer.h : Declaration of the CProfilerCallbackServer

#pragma once
#include "resource.h"       // main symbols

#include "Undisposed_i.h"
#include "Controller.h"


#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif



// CProfilerCallbackServer

class ATL_NO_VTABLE CProfilerCallbackServer :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CProfilerCallbackServer, &CLSID_ProfilerCallbackServer>,
	public IDispatchImpl<IProfilerCallbackServer, &IID_IProfilerCallbackServer, &LIBID_UndisposedLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
	public ICorProfilerCallback2
{
private:
	Controller controller;
public:
	CProfilerCallbackServer()
	{
	}

	DECLARE_REGISTRY_RESOURCEID(IDR_PROFILERCALLBACKSERVER)


	BEGIN_COM_MAP(CProfilerCallbackServer)
		COM_INTERFACE_ENTRY(IProfilerCallbackServer)
		COM_INTERFACE_ENTRY(IDispatch)
		COM_INTERFACE_ENTRY(ICorProfilerCallback)
		COM_INTERFACE_ENTRY(ICorProfilerCallback2)
	END_COM_MAP()



	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

public:


	// ICorProfilerCallback2 Methods
public:
	virtual HRESULT STDMETHODCALLTYPE ThreadNameChanged( 
		/* [in] */ ThreadID threadId,
		/* [in] */ ULONG cchName,
		/* [in] */ WCHAR name[  ]) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE GarbageCollectionStarted( 
		/* [in] */ int cGenerations,
		/* [length_is][size_is][in] */ BOOL generationCollected[  ],
		/* [in] */ COR_PRF_GC_REASON reason) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE SurvivingReferences( 
		/* [in] */ ULONG cSurvivingObjectIDRanges,
		/* [size_is][in] */ ObjectID objectIDRangeStart[  ],
		/* [size_is][in] */ ULONG cObjectIDRangeLength[  ]) 
	{ 
		return controller.SurvivingReferences(cSurvivingObjectIDRanges, objectIDRangeStart, cObjectIDRangeLength);
	}

	virtual HRESULT STDMETHODCALLTYPE GarbageCollectionFinished( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE FinalizeableObjectQueued( 
		/* [in] */ DWORD finalizerFlags,
		/* [in] */ ObjectID objectID) { return controller.FinalizeableObjectQueued(finalizerFlags, objectID); }

	virtual HRESULT STDMETHODCALLTYPE RootReferences2( 
		/* [in] */ ULONG cRootRefs,
		/* [size_is][in] */ ObjectID rootRefIds[  ],
		/* [size_is][in] */ COR_PRF_GC_ROOT_KIND rootKinds[  ],
		/* [size_is][in] */ COR_PRF_GC_ROOT_FLAGS rootFlags[  ],
		/* [size_is][in] */ UINT_PTR rootIds[  ]) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE HandleCreated( 
		/* [in] */ GCHandleID handleId,
		/* [in] */ ObjectID initialObjectId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE HandleDestroyed( 
		/* [in] */ GCHandleID handleId) { return S_OK; }

	// ICorProfilerCallback Methods
public:
	virtual HRESULT STDMETHODCALLTYPE Initialize( 
		/* [in] */ IUnknown *pICorProfilerInfoUnk) { return controller.Initialize(pICorProfilerInfoUnk); }

	virtual HRESULT STDMETHODCALLTYPE Shutdown( void) { return controller.Shutdown(); }

	virtual HRESULT STDMETHODCALLTYPE AppDomainCreationStarted( 
		/* [in] */ AppDomainID appDomainId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE AppDomainCreationFinished( 
		/* [in] */ AppDomainID appDomainId,
		/* [in] */ HRESULT hrStatus) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE AppDomainShutdownStarted( 
		/* [in] */ AppDomainID appDomainId) { return controller.AppDomainShutdownStarted(); }

	virtual HRESULT STDMETHODCALLTYPE AppDomainShutdownFinished( 
		/* [in] */ AppDomainID appDomainId,
		/* [in] */ HRESULT hrStatus) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE AssemblyLoadStarted( 
		/* [in] */ AssemblyID assemblyId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE AssemblyLoadFinished( 
		/* [in] */ AssemblyID assemblyId,
		/* [in] */ HRESULT hrStatus) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE AssemblyUnloadStarted( 
		/* [in] */ AssemblyID assemblyId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE AssemblyUnloadFinished( 
		/* [in] */ AssemblyID assemblyId,
		/* [in] */ HRESULT hrStatus) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ModuleLoadStarted( 
		/* [in] */ ModuleID moduleId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ModuleLoadFinished( 
		/* [in] */ ModuleID moduleId,
		/* [in] */ HRESULT hrStatus) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ModuleUnloadStarted( 
		/* [in] */ ModuleID moduleId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ModuleUnloadFinished( 
		/* [in] */ ModuleID moduleId,
		/* [in] */ HRESULT hrStatus) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ModuleAttachedToAssembly( 
		/* [in] */ ModuleID moduleId,
		/* [in] */ AssemblyID AssemblyId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ClassLoadStarted( 
		/* [in] */ ClassID classId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ClassLoadFinished( 
		/* [in] */ ClassID classId,
		/* [in] */ HRESULT hrStatus) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ClassUnloadStarted( 
		/* [in] */ ClassID classId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ClassUnloadFinished( 
		/* [in] */ ClassID classId,
		/* [in] */ HRESULT hrStatus) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE FunctionUnloadStarted( 
		/* [in] */ FunctionID functionId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE JITCompilationStarted( 
		/* [in] */ FunctionID functionId,
		/* [in] */ BOOL fIsSafeToBlock) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE JITCompilationFinished( 
		/* [in] */ FunctionID functionId,
		/* [in] */ HRESULT hrStatus,
		/* [in] */ BOOL fIsSafeToBlock) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE JITCachedFunctionSearchStarted( 
		/* [in] */ FunctionID functionId,
		/* [out] */ BOOL *pbUseCachedFunction) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE JITCachedFunctionSearchFinished( 
		/* [in] */ FunctionID functionId,
		/* [in] */ COR_PRF_JIT_CACHE result) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE JITFunctionPitched( 
		/* [in] */ FunctionID functionId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE JITInlining( 
		/* [in] */ FunctionID callerId,
		/* [in] */ FunctionID calleeId,
		/* [out] */ BOOL *pfShouldInline) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ThreadCreated( 
		/* [in] */ ThreadID threadId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ThreadDestroyed( 
		/* [in] */ ThreadID threadId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ThreadAssignedToOSThread( 
		/* [in] */ ThreadID managedThreadId,
		/* [in] */ DWORD osThreadId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RemotingClientInvocationStarted( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RemotingClientSendingMessage( 
		/* [in] */ GUID *pCookie,
		/* [in] */ BOOL fIsAsync) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RemotingClientReceivingReply( 
		/* [in] */ GUID *pCookie,
		/* [in] */ BOOL fIsAsync) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RemotingClientInvocationFinished( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RemotingServerReceivingMessage( 
		/* [in] */ GUID *pCookie,
		/* [in] */ BOOL fIsAsync) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RemotingServerInvocationStarted( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RemotingServerInvocationReturned( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RemotingServerSendingReply( 
		/* [in] */ GUID *pCookie,
		/* [in] */ BOOL fIsAsync) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE UnmanagedToManagedTransition( 
		/* [in] */ FunctionID functionId,
		/* [in] */ COR_PRF_TRANSITION_REASON reason) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ManagedToUnmanagedTransition( 
		/* [in] */ FunctionID functionId,
		/* [in] */ COR_PRF_TRANSITION_REASON reason) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RuntimeSuspendStarted( 
		/* [in] */ COR_PRF_SUSPEND_REASON suspendReason) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RuntimeSuspendFinished( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RuntimeSuspendAborted( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RuntimeResumeStarted( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RuntimeResumeFinished( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RuntimeThreadSuspended( 
		/* [in] */ ThreadID threadId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RuntimeThreadResumed( 
		/* [in] */ ThreadID threadId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE MovedReferences( 
		/* [in] */ ULONG cMovedObjectIDRanges,
		/* [size_is][in] */ ObjectID oldObjectIDRangeStart[  ],
		/* [size_is][in] */ ObjectID newObjectIDRangeStart[  ],
		/* [size_is][in] */ ULONG cObjectIDRangeLength[  ]) 
	{ 
		return controller.MovedReferences(cMovedObjectIDRanges,
			oldObjectIDRangeStart, newObjectIDRangeStart, cObjectIDRangeLength);
	}

	virtual HRESULT STDMETHODCALLTYPE ObjectAllocated( 
		/* [in] */ ObjectID objectId,
		/* [in] */ ClassID classId) { return controller.ObjectAllocated(objectId, classId); }

	virtual HRESULT STDMETHODCALLTYPE ObjectsAllocatedByClass( 
		/* [in] */ ULONG cClassCount,
		/* [size_is][in] */ ClassID classIds[  ],
		/* [size_is][in] */ ULONG cObjects[  ]) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ObjectReferences( 
		/* [in] */ ObjectID objectId,
		/* [in] */ ClassID classId,
		/* [in] */ ULONG cObjectRefs,
		/* [size_is][in] */ ObjectID objectRefIds[  ]) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE RootReferences( 
		/* [in] */ ULONG cRootRefs,
		/* [size_is][in] */ ObjectID rootRefIds[  ]) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionThrown( 
		/* [in] */ ObjectID thrownObjectId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionSearchFunctionEnter( 
		/* [in] */ FunctionID functionId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionSearchFunctionLeave( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionSearchFilterEnter( 
		/* [in] */ FunctionID functionId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionSearchFilterLeave( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionSearchCatcherFound( 
		/* [in] */ FunctionID functionId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionOSHandlerEnter( 
		/* [in] */ UINT_PTR __unused) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionOSHandlerLeave( 
		/* [in] */ UINT_PTR __unused) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionUnwindFunctionEnter( 
		/* [in] */ FunctionID functionId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionUnwindFunctionLeave( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionUnwindFinallyEnter( 
		/* [in] */ FunctionID functionId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionUnwindFinallyLeave( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionCatcherEnter( 
		/* [in] */ FunctionID functionId,
		/* [in] */ ObjectID objectId) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionCatcherLeave( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE COMClassicVTableCreated( 
		/* [in] */ ClassID wrappedClassId,
		/* [in] */ REFGUID implementedIID,
		/* [in] */ void *pVTable,
		/* [in] */ ULONG cSlots) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE COMClassicVTableDestroyed( 
		/* [in] */ ClassID wrappedClassId,
		/* [in] */ REFGUID implementedIID,
		/* [in] */ void *pVTable) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionCLRCatcherFound( void) { return S_OK; }

	virtual HRESULT STDMETHODCALLTYPE ExceptionCLRCatcherExecute( void) { return S_OK; }
};

	OBJECT_ENTRY_AUTO(__uuidof(ProfilerCallbackServer), CProfilerCallbackServer)
